#include <iostream>
using namespace std;

template <typename T>
class Aipoint
{
public:
    Aipoint(int size)
    {
        p = new T[size];
        this->size = size;
        cout << "构造函数" << endl;
    }

    T &operator[](int index)
    {
        if (index >= size)
        {
            cout << "index out of range" << endl;
            return p[size - 1];
        }
        else
        {
            return p[index];
        }
    }
    void setValue(T value, int n)
    {
        p[n] = value;
    }

private:
    T *p;
    int size;
};

int main()
{
    Aipoint<int> a(5);

    for (int i = 0; i < 5; i++)
    {
        a[i] = i * i;
    }

    for (int i = 0; i < 5; i++)
    {

        cout << a[i] << endl;
    }

    return 0;
}